# import os
# import time
#
# from PIL import Image
#
#
# def list_files(directory):
#     my_list = []
#     for root, dirs, files in os.walk(directory):
#         for file in files:
#             my_list.append(os.path.join(root, file))
#     return my_list
#
#
# if __name__ == '__main__':
#     """
#     把D:\\1\\的tga图片转换成png并存储到D:\\2\\
#     """
#     print('开始')
#     timestamp = int(time.time())
#     my_list = list_files('D:\\1')
#     for element in my_list:
#         _, file_extension = os.path.splitext(element)
#         if file_extension.lower() == '.tga':
#             tga_image = Image.open(element)
#             rgba_image = tga_image.convert("RGBA")
#             target_dir = os.path.dirname(element.replace("D:\\1\\", "D:\\2\\"))
#             os.makedirs(target_dir, exist_ok=True)
#             rgba_image.save(element.replace("D:\\1\\", "D:\\2\\").replace(".tga", ".png"))
#     endTime = int(time.time())
#     print(str(endTime - timestamp))
#     print('结束')
